package com.sales.service.impl;

import com.sales.dao.AccountDao;
import com.sales.entity.Account;
import com.sales.service.AccountService;
import com.sales.util.UuidUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by lihu on 2017/9/12.
 */
@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    AccountDao accountDao;

    @Override
    public void createAccount(String username) {
        Account account = accountDao.findByUsername(username);
        if (account == null) {
            account = new Account(UuidUtil.getUuid(), username);
            accountDao.save(account);
        }
    }

    @Override
    public Account getAccount(String username) {
        return accountDao.findByUsername(username);
    }
}
